//
// Created by chezi008 on 2020/1/15.
//

#ifndef ONVIFTEMP3_DEVICE_H
#define ONVIFTEMP3_DEVICE_H

#include <string>
#include "onvifmsg.h"
#include <stdio.h>

#define SERVICE_INDEX_MEDIA  0
#define SERVICE_INDEX_PTZ  1
#define SERVICE_INDEX_EVENT  2
#define SERVICE_INDEX_SEARCH  3
#define SERVICE_INDEX_RECORDING 4

class Device {
private:
    ONVIF onvifmsg;
    string onvif_addr;
    string source_token;

    void GetDevInfo();
    void GetOnvifServeAddr();


public:
    string username;
    string pwd;
    string ip;
    string dev_name;
    string dev_type;
    map<string, PassMsg> map_passmsg;
    vector<string> vec_service;

    Device(string username, string pwd, string ip) {
        this->username = username;
        this->pwd = pwd;
        this->ip = ip;
        char addr[128] = {0};
        sprintf(addr, "http://%s/onvif/device_service", ip.c_str());
        onvif_addr.append(addr);
        GetDevInfo();
        GetOnvifServeAddr();
    }

    ~Device() {}

    void GetOnvifMediaUri();
    void SetTokenByUri(string uri);
    int DoPtz(int ptz_type, int ptz_command, float ptz_speed);
    int PtzStop();
};


#endif //ONVIFTEMP3_DEVICE_H
